import os
import zipfile
from pathlib import Path


def demo_zip():
    cwd = os.getcwd()
    cwd = Path(cwd).resolve()
    wd = cwd.parent
    folder_path = os.path.join(wd, "demo")

    zip_path = os.path.join(wd, "apitest/demo.zip")
    zip_file = zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED)

    for root, dirs, files in os.walk(folder_path):
        for file in (files + dirs):
            file_path = os.path.join(root, file)
            zip_file.write(file_path, os.path.relpath(file_path, folder_path))
    zip_file.close()


if __name__ == '__main__':
    demo_zip()
